<script lang="ts" setup>
import { isIOS, isMiniProgram } from "@/utils/mini-program";
import { showDialog } from "@nutui/nutui";
import "@nutui/nutui/dist/packages/dialog/style";

const props = defineProps<{
  isFree?: boolean;
  purchased?: boolean;
}>();

const handleBuy = inject<(e: "buy") => void>("handleBuy");

const handlePrompt = () => {
  showDialog({
    title: "提示",
    content: "咨询驾校工作人员",
    noCancelBtn: true,
    onCancel: () => {},
    onOk: () => {},
  });
};

const cantBuy = computed(() => isIOS() && isMiniProgram() && !props.isFree);
</script>

<template>
  <!-- 底部栏 -->
  <template v-if="!purchased">
    <div class="h-18"></div>
    <div class="fixed bottom-0 left-0 right-0 px-3 pb-3 pt-2 bg-white b-t b-t-gray-2">
      <nut-button v-if="!cantBuy" type="primary" size="large" block @click="handleBuy"> 立即{{ isFree ? "报名" : "购买" }}</nut-button>
      <nut-button v-else type="primary" size="large" block @click="handlePrompt"> 课程咨询 </nut-button>
    </div>
  </template>
</template>
